package Main;

import java.util.List;

import Algoritmo.LZW;
import Conversions.Convert;

public class MainLZW {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		LZW lzw = new LZW();
		Convert convert = new Convert();
		
		
		byte[] c = convert.fileToByteStream("txt.txt");
		for (int i = 0; i < c.length; i++) {
			System.out.print(c[i] + " ");
		}
		System.out.println("");
		byte[] code = (byte[]) lzw.compress(c);
		
		
		convert.byteToFileStream(code , "arq.cpm");
		
		
		byte[] decode = convert.fileToByteStream("arq.cpm");
		
		List<Byte> o = lzw.descompress(decode);
		byte[] b = new byte[o.size()];
		for (int i = 0; i < b.length; i++) {
			b[i] = o.get(i);
		}
		
		for (int i = 0; i < b.length; i++) {
			System.out.print(b[i] + " ");
		}
		
		convert.byteToFileStream(b, "copy.txt") ;
		
	}

}
